//
//  Outcome+Outcome.m
//  ClinicalCollections
//
//  Created by janakiraman gopinath on 5/18/13.
//  Copyright (c) 2013 GOPI. All rights reserved.
//

#import "Outcome+Outcome.h"

@implementation Outcome (Outcome)

+ (void) outcome:(NSArray *) outcomes
            type:(NSString *) type
      forContext:(NSManagedObjectContext *)context
forClinicalTrialGov:(ClinicalTrialGov *)clinicalTrialGov
{
    for (NSDictionary *outcomeDict in outcomes) {
        Outcome  *outcome = (Outcome *)[NSEntityDescription insertNewObjectForEntityForName:@"Outcome"
                                                                     inManagedObjectContext:context];
        if (!([[outcomeDict valueForKey:@"description"] isEqual:[NSNull null]]))
            outcome.desc = [outcomeDict valueForKey:@"description"];
        if (!([[outcomeDict valueForKey:@"safety_issue"] isEqual:[NSNull null]]))
            outcome.safety_issues = [outcomeDict valueForKey:@"safety_issue"];
        if (!([[outcomeDict valueForKey:@"time_frame"] isEqual:[NSNull null]]))
            outcome.time_frame = [outcomeDict valueForKey:@"time_frame"];
       if (!([[outcomeDict valueForKey:@"measure"] isEqual:[NSNull null]]))
           outcome.measure = [outcomeDict valueForKey:@"measure"];
        outcome.type = type;
        outcome.clinicalTrialGov = clinicalTrialGov;
    }
    return;
}

@end
